<?php

class Application_Model_Book extends Ahs_Model
{

    /**
     * @var integer
     */
    protected $_id;
    /**
     * @var integer
     */
    protected $_author_id;
    /**
     * @var string
     */
    protected $_title;
    /**
     * @var string
     */
    protected $_subtitle;
    /**
     * @var string
     */
    protected $_description;
    /**
     * @var string
     */
    protected $_image;
    /**
     * @var datetime
     */
    protected $_creationdate;
    /**
     * @var datetime
     */
    protected $_modifieddate;
    /**
     * @var datetime
     */
    protected $_deleteddate;
    
    /**
     * @return integer
     */    
    public function getId() {
        return $this->_id;
    }
    /**
     * @param integer $id
     */
    public function setId($id) {
        $this->_id = $id;
    }
    
     /**
     * @return integer
     */    
    public function getAuthorId() {
        return $this->_author_id;
    }
    /**
     * @param integer $id
     */
    public function setAuthorId($id) {
        $this->_author_id = $id;
    }
    /**
     * Get the author object
     * @return Application_Model_User
     */
    public function getAuthor()
    {
        if($this->_author_id != null)
        {
            // Get author
            $mapper = new Application_Model_UserMapper();
            return $mapper->fetchById($this->_author_id);
        }
        
        return null;
    }

    /**
     * @return string
     */
    public function getTitle() {
        return $this->_title;
    }
    /**
     * @param string $subject
     */
    public function setTitle($title) {
        $this->_title = $title;
    }
    
    /**
     * @return string
     */
    public function getSubtitle() {
        return $this->_subtitle;
    }
    /**
     * @param string $subtitle
     */
    public function setSubtitle($subtitle) {
        $this->_subtitle = $subtitle;
    }
    
    /**
     * @return string
     */
    public function getDescription() {
        return $this->_description;
    }
    /**
     * @param string $description
     */
    public function setDescription($description) {
        $this->_description = $description;
    }
    
    /**
     * @return string
     */
    public function getImage() {
        return $this->_image;
    }
    /**
     * @param string $image
     */
    public function setImage($image) {
        $this->_image = $image;
    }
    
    /**
     * @return datetime
     */
    public function getCreationDate() {
        return $this->_creationdate;
    }
    /**
     * @param datetime $date
     */
    public function setCreationDate($date) {
        $this->_creationdate = $date;
    }
    
    /**
     * @return datetime
     */
    public function getModifiedDate() {
        return $this->_modifieddate;
    }
    /**
     * @param datetime $date
     */
    public function setModifiedDate($date) {
        $this->_modifieddate = $date;
    }
    
    /**
     * @return datetime
     */
    public function getDeletedDate() {
        return $this->_deleteddate;
    }
    /**
     * @param datetime $date
     */
    public function setDeletedDate($date) {
        $this->_deleteddate = $date;
    }
    
    /**
     * @return array
     */
    public function getChapters()
    {
        if($this->_id != null)
        {
            // Get chapters
            $mapper = new Application_Model_ChapterMapper();
            return $mapper->fetchByBookId($this->_id);
        }
        
        return null;
    }
    
    /**
     * @return array
     */
    public function getReviews()
    {
        if($this->_id != null)
        {
            // Get reviews
            $mapper = new Application_Model_ReviewMapper();
            return $mapper->fetchByBookId($this->_id);
        }
        
        return null;
    }
}

